package nz.ac.massey.cs.se400_2013.ass3.tests;

import java.beans.XMLEncoder;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList;

import nz.ac.massey.cs.se400_2013.ass3.Address;
import nz.ac.massey.cs.se400_2013.ass3.Course;
import nz.ac.massey.cs.se400_2013.ass3.Paper;
import nz.ac.massey.cs.se400_2013.ass3.Student;

public class DataGeneration {
 
	public static void main(String[] args) throws FileNotFoundException{
		ArrayList<Course> courses = new ArrayList<Course>();
		Course course1 = new Course();
		course1.setName("Computer science");
		courses.add(course1);
		Course course2 = new Course();
		course2.setName("Information Technology");
		courses.add(course2);
		Course course3 = new Course();
		course3.setName("Something non CS related");
		courses.add(course3);
		
		// For a student test.
		Address address1 = new Address();
		address1.setStreet("LOL");
		address1.setNo(1);
		address1.setCity("PN");
		
		Student student1 = new Student();
		student1.setName("Chen");
		student1.setFirstName("Zheng");
		student1.setAddress(address1);
		
		Paper paper1 = new Paper();
		paper1.setName("cs 101");
		paper1.addStudent(student1);
		
		Paper paper2 = new Paper();
		paper2.setName("cs 102");
		
		Paper paper3 = new Paper();
		paper3.setName("cs 103");
		
		
		Student student2 = new Student();
		student2.setName("Daniel");
		
		Student student3 = new Student();
		student3.setName("Jim");
		
		paper1.addStudent(student2);
		paper1.addStudent(student3);
		
		course1.addPaper(paper1);
		course1.addPaper(paper2);
		course1.addPaper(paper3);
		FileOutputStream out = new FileOutputStream("data1.xml");
		XMLEncoder encoder = new XMLEncoder(out);
		encoder.writeObject(courses);
		encoder.flush();
	}
}
